﻿using System.Web;

namespace Codemonk.Pease.Server.ObjectDecorators
{
    public class HttpContextDecorator : IObjectDecorator<HttpContext>
    {
        public void Decorate(object instance, HttpContext context)
        {
            try
            {
                var type = instance.GetType();
                var prop = type.GetProperty("CurrentContext");
                if (prop != null)
                {
                    prop.SetValue(instance, context, null);
                }
            }
            catch { }
        }
    }
}
